package nc.bs.voucher.report;

import nc.vo.me.report.pub.DataViewUtil;
import nc.vo.pub.JavaType;
import nc.vo.pubapp.pattern.model.meta.entity.view.DataViewMeta;
import nc.vo.pubapp.pattern.model.meta.entity.vo.Attribute;
import nc.vo.pubapp.pattern.model.meta.table.Column;

public class VoucherReportResultViewMeta extends DataViewMeta{ 
	public static final String VOUCHER_YEAR        = "voucher_year"; 
	public static final String PERIOD      = "period";
	public static final String VOUCHER_NO  = "voucher_no"; 
	public static final String ATTACHMENT  = "attachment";
	public static final String PZSUM       = "pzsum";
	public static final String HJ          = "hj";
	public static final String ORGCODE     = "orgcode";
	public static final String ORGNAME     = "orgname";
	
	public VoucherReportResultViewMeta()
	{
		super();
		this.init();
	}
	private void init()
	{
		this.addAttributes(new String[] { ATTACHMENT,
				PZSUM,
				HJ,
				}, JavaType.UFDouble);
		this.addAttributes(new String[] { 
				VOUCHER_YEAR,
				PERIOD,
				VOUCHER_NO,
				ORGCODE,
				ORGNAME
				}, JavaType.String);
//		 this.addAttributes(new String[] { BILLDATE }, JavaType.UFDate);
	}
	private void addAttributes(String[] attributes, JavaType type)
	{
		for (String attr : attributes)
		{
			Column column = new Column(null, attr);
			int sqltype = new DataViewUtil().getTypeComparison().get(type).intValue();
			column.setSqlType(sqltype);
			if (type == JavaType.UFDouble)
			{
				column.setLength(28);
				column.setPrecision(8);
			}
			else if (type == JavaType.String)
			{
				column.setLength(300);
				column.setPrecision(0);
			}
			Attribute attribute = new Attribute(attr, column, null);
			attribute.setJavaType(type);
			attribute.setCustom(false);
			attribute.setStatic(false);
			attribute.setPersistence(false);
			attribute.setSerializable(true);
			this.add(attribute);
		}
	}
}
